<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="../static/layui/css/layui.css">
</head>
<body class="layui-layout-body">

<div class="layui-form" lay-filter="layuiadmin-form-cate" id="layuiadmin-form-cate" style="padding: 20px 30px 0 0;">

    <div class="layui-form-item">
        <label class="layui-form-label">权限</label>
        <div class="layui-input-block">
            <select name="userRole" id="userRoleSelect">

            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" id="username" lay-verify="required" placeholder="请输入用户名" autocomplete="off"
                   class="layui-input"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off"
                   class="layui-input"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="real_name" lay-verify="required" placeholder="请输入姓名" autocomplete="off"
                   class="layui-input" value=""/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input type="text" name="phone" lay-verify="required" placeholder="手机号" autocomplete="off"
                   class="layui-input" value=""/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="text" name="email" lay-verify="required" placeholder="请输入邮箱" autocomplete="off"
                   class="layui-input" value=""/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司名</label>
        <div class="layui-input-block">
            <input type="text" name="company_name" lay-verify="required" placeholder="请输入公司名" autocomplete="off"
                   class="layui-input" value=""/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">分类</label>
        <div class="layui-input-block">
            <select name="account_type" id="accountTypeSelect">
                <option value="0">个人</option>
                <option value="1">企业</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-submit" id="LAY-submit" value="确认">
    </div>
</div>
<script src="/static/js/jquery.min.js" media="all"></script>
<script src="../static/layui/layui.js"></script>
<script>
    layui.use('element', function () {
        var element = layui.element;
    });
    layui.use('form', function () {            //渲染select
        let form = layui.form;
        //请求获取角色下拉列表
        $.ajax({
            url: "/user/getRole",
            type: 'POST',
            dataType: 'json',
            error: function () {
                layer.msg('出错啦。。。');
            },
            success: function (result) {        //动态渲染下拉列表
                for (let i = 0; i < result.length; i++) {
                    $("#userRoleSelect").append("<option value='" + result[i].id + "'>" + result[i].permission_name + "</option>");//新增
                    form.render();
                }
            }
        });
    });
</script>
</body>
</html>
